import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '@/views/login')
  },
  {
    path: '/',
    name: 'layout',
    component: () => import(/* webpackChunkName: "layout" */ '@/views/layout'),
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import(/* webpackChunkName: "home" */ '@/views/home')
      }, {
        path: '/message',
        name: 'message',
        component: () => import(/* webpackChunkName: "message" */ '@/views/message')
      }, {
        path: '/video',
        name: 'video',
        component: () => import(/* webpackChunkName: "video" */ '@/views/video')
      }, {
        path: '/mine',
        name: 'mine',
        component: () => import(/* webpackChunkName: "mine" */ '@/views/mine')
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import(/* webpackChunkName: "search" */ '@/views/search')
  },
  {
    path: '/article/:articleId',//动态路由
    name: 'article',
    component: () => import(/* webpackChunkName: "article" */ '@/views/article'),
    props: true, //开启props传参=>把路由参数映射到组件props中
  }
]

const router = new VueRouter({
  routes
})

export default router
